package com.zhangxin.aiInterview.manager.asr;

import com.zhangxin.aiInterview.common.ErrorCode;
import com.zhangxin.aiInterview.exception.BusinessException;
import lombok.extern.slf4j.Slf4j;
import org.vosk.Model;

import java.io.IOException;

import static com.zhangxin.aiInterview.constant.ModelConstant.*;

/**
 * 单例模式（全局只初始化一个语音转文字大模型）
 * 饿汉式加载 利用JVM类加载机制
 */
@Slf4j
@Deprecated
public class AudioToWordsModel {
    private static final Model model;

    static {
        try {
            model = new Model(MODEL_PATH);
        } catch (IOException e) {
            throw new BusinessException(ErrorCode.OPERATION_ERROR,"模型加载失败");
        }
    }
    //获取实例的方法
    public static Model getInstance() {
        return model;
    }
}
